<?php

use yii\helpers\Html;
use yii\grid\GridView;


$this->title = Yii::t('app', 'Costs');
$this->params['breadcrumbs'][] = $this->title;
?>
<style type="text/css">
    .cs1{margin:2px 5px;} 
</style>

<div class="cost-index">

    <div class="box">
        <div class="box-header">
            <h4>我的团组</h4>   
        </div>
        <div class="box-body">
        <p>
             <?php echo $this->render('_search', ['model' => $searchModel]); ?>
        </p>
        <?= GridView::widget([
            'dataProvider' => $dataProvider,
            'layout'  =>  "{items}\n{summary}\n{pager}",
            'columns' => [
                ['class' => 'yii\grid\SerialColumn'],

                [
                    'attribute' => Yii::t('app.customer', 'Name'),
                    'headerOptions' => ['width' => '15%'],
                    'value' => function ($model) {
                            return $model->customer->name;
                        },
                ],
 
                [
                    'attribute' => Yii::t('app.product', 'Code'),
                    'headerOptions' => ['width' => '15%'],
                    'value' => function ($model) {
                            return $model->code;
                        },
                ],
                [
                    'attribute' => Yii::t('app.product', 'Name'),
                    'headerOptions' => ['width' => '15%'],
                    'value' => function ($model) {
                            return $model->name;
                        },
                ],
                [
                    'attribute' => Yii::t('app.product', 'Price'),
                    'headerOptions' => ['width' => '10%'],
                    'value' => function ($model) {
                            return $model->price;
                    },
                ],
                [
                    'attribute' => Yii::t('app.product', 'Cost Price'),
                    'headerOptions' => ['width' => '10%'],
                    'value' => function ($model) {
                            return $model->costPrice;
                    },
                ],

                [
                    'attribute' => Yii::t('app', 'Status'),
                    'headerOptions' => ['width' => '10%'],
                    'filter' =>  Yii::$app->params['product_status'],
                    'value' => function ($model) {
                            return isset(Yii::$app->params['product_status'][$model->status])?Yii::$app->params['product_status'][$model->status]:'';
                        },
                ],

                [
                      'attribute' => Yii::t('app.product', 'Oper ID'),
                      'headerOptions' => ['width' => '10%'],
                      'value' => function($model){

                            return $model->operName;
                      }
                ],
                
                [
                    'label'=>'操作',
                    'headerOptions' => ['width' => '15%'],
                    'format'=>'raw',
                    'value' => function($model){

                        $url  = sprintf("/cost/cost/cost?product_id=%d", $model->id); //成本项
                        $url2= sprintf("/cost/cost/detail?product_id=%d", $model->id); //报价单
                        
                        $url3= sprintf("/product/tour/index?product_id=%d", $model->id); //团队导游

                        $url4= sprintf("/product/serve/index?product_id=%d", $model->id); //服务经理

                        $str  = Html::a('成本项',$url,['title' =>'成本项','class'=>'btn btn-primary btn-xs cs1','target'=>'_blank']);

                        $str .= Html::a('报价单',$url2,['title' =>'报价单','class'=>'btn btn-info btn-xs cs1','target'=>'_blank']);

                        $str .= Html::a('团队导游',$url3,['title' =>'团队导游','class'=>'btn btn-danger btn-xs cs1','target'=>'_blank']);

                        $str .= Html::a('服务经理',$url4,['title' =>'服务经理','class'=>'btn btn-warning btn-xs cs1','target'=>'_blank']);

                        return $str;
                     }
                ],
            ],
        ]); ?>
        </div>
    </div>

</div>
